<template>
    <div class="content" @click="gotoCartoon(data)">
        <div class="img">
            <img v-lazy="data.vertical_cover ? data.vertical_cover :data.image"/>
        </div>
        <div class="name">{{data.title}}</div>
        <div class="title">
            <div class="titleCont" >
                <span v-if="data.decision_info">{{data.decision_info}}</span>
                <div v-else-if="data.styles">{{data.styles[0].name}}</div>
                
                <div v-if="data.comic_info">
                    <span v-if="data.comic_info.decision!=''">{{data.comic_info.decision}}</span>
                    <div v-else-if="data.comic_info.main_style_name">{{data.comic_info.main_style_name}}</div>
                    <div v-else-if="data.comic_info.lastest_short_title">{{data.comic_info.lastest_short_title | replace}}</div>
                </div>
                
            </div>
            <div class="icon" v-if="data.labels" @click.stop="binIcon(data.comic_id ? data.comic_id:data.item_id)">
                <van-icon name="ellipsis" />
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        props:{
            'data':Object
        },
        data() {
            return {
                // show:true
            }
        },
        methods:{
            binIcon(v){
                this.$emit('isShow',v)
            },

            // 跳内容
            gotoCartoon(item){
                
                let num = '';
                if(item.comic_id === undefined){
                    num = item.item_id
                }else{
                    num = item.comic_id
                }
                this.$router.push({name:"CartoonContainer",query:{id:num}})
            }
        },
        filters:{
            replace(v){
                let pattern = /\d+/;
                return '更新至'+pattern.exec(v)+'话'
            }
        }
    }
</script>

<style lang="less" scoped>
    .content{
        margin-top: 20px;
        width: 48%;
        border-radius: 5px;
        overflow: hidden;
        outline: 1px solid #f4f4f4;
        .img{
            width: 100%;
            img{
                width: 100%;
                min-height: 227px;
                display: block;
            }
        }
        .name{
            height: 25px;
            line-height: 25px;
            padding: 0 5px;
            box-sizing: border-box;
            text-overflow: ellipsis;
            white-space: nowrap;
            overflow: hidden;
        }
        .title{
            display: flex;
            padding: 0 5px;
            box-sizing: border-box;
            justify-content: space-between;
            margin: 10px 0;
            .titleCont{
                span{
                    padding: 5px;
                    background-color: #fefaf3;
                    color: #f2a340;
                }
            }
            .icon{
                width: 25px;
                height: 25px;
                font-size: 20px;
                text-align: center;
                line-height: 25px;
                color: rgb(146, 146, 146);
            }
        }
    }
</style>